package com.hancher.gamelife2.function;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

import io.reactivex.rxjava3.core.Flowable;

/**
 * 描述 :  <br/>
 * 时间 : 2023/12/2 13:26 <br/>
 * 作者 : Hancher ytu_shaoweijie@163.com
 */
@Dao
public interface IFunctionDao {
    @Insert
    void insertItem(FunctionPO data);

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    void insertList(List<FunctionPO> datas);

    @Delete
    void deleteItem(FunctionPO data);

    @Update
    void updateItem(FunctionPO data);

    @Query("SELECT * FROM function")
    List<FunctionPO> getAll();

    @Query("SELECT * FROM function ORDER BY clickCount DESC LIMIT 1")
    FunctionPO getClickMaxItem();

    @Query("SELECT * FROM function ORDER BY updateTime DESC LIMIT 1")
    FunctionPO getRecentItem();

    @Query("SELECT * FROM function")
    Flowable<List<FunctionPO>> getAllAsync();

    @Query("SELECT * FROM function WHERE md5 = :md5 LIMIT 1")
    FunctionPO getItemByMd5(String md5);

//    @Query("SELECT * FROM function WHERE uuid = :tag")
//    Flowable<List<FunctionPO>> getItemAsyncByTag(String tag);
//    @Query("SELECT * FROM function WHERE uuid = :tag")
//    List<FunctionPO> getItemByTag(String tag);
}
